package com.cdl.library.view;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ProgressBar;

import com.cdl.library.R;


public class WaitDialogUtil {

    Dialog waitDialog;
    Context context;
    public static final String TAG = WaitDialogUtil.class.getName();

    public WaitDialogUtil(Context context) {
        this.context = context;
        waitDialog = new Dialog(context, R.style.MyDialog_Base);
        View dialogWait = View.inflate(context, R.layout.dialog_wait, null);
        waitDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        waitDialog.setContentView(dialogWait);
        waitDialog.setCanceledOnTouchOutside(false);
        waitDialog.setCancelable(true);
        Window window = waitDialog.getWindow();
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    }


    /***
     * 用来显示在fragment中心位置
     */
    public void showDialog() {
        if (waitDialog.isShowing()) {
            return;
        }
        waitDialog.show();
    }

    public void cancelDialog() {
        if (waitDialog == null) {
            return;
        }
        if (waitDialog.isShowing()) {
            waitDialog.dismiss();
        }
    }
}
